package Managers;

import Models.Book;
import UserView.BookList;

/**
 * Created with IntelliJ IDEA.
 * User: Shreyansh
 * Date: 22/8/13
 * Time: 10:42 PM
 * To change this template use File | Settings | File Templates.
 */
public class BookManager {

    public void reserveBook(String bookToReserve,BookList bookList) {
        boolean isBookPresent=false;
        int indexOfBook=0;
        for(Book book:bookList.getBookList())
        {
            if(book.bookname.equals(bookToReserve))
            {

                isBookPresent=true;
                if (bookList.quantityOfBook[indexOfBook]!=0)
                {
                    bookList.quantityOfBook[indexOfBook]--;
                    System.out.println("Book reserved successfully");
                    break;
                }
                else
                {
                    System.out.println("Sorry Book not available");
                    break;
                }
            }
            indexOfBook++;
        }
        if(isBookPresent==false)

            System.out.println("Sorry we do not have this Book");
    }
}
